<div class="layuimini-main">

    <div class="layui-form layuimini-form" lay-filter="updateSubmit">
        <input type="hidden" name="id">
        <input type="hidden" name="typeIds" id="typeIds">
        <div class="layui-form-item">
            <label class="layui-form-label required">旧密码</label>
            <div class="layui-input-block">
                <input type="password" name="oldPwd" lay-verify="required" lay-reqtext="旧密码不能为空"
                       value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">新密码</label>
            <div class="layui-input-block">
                <input type="password" name="newPwd" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">确认密码</label>
            <div class="layui-input-block">
                <input type="password" name="confirmPwd" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="updateSubmit">确认修改</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table'], function () {
        let form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;
        form.render();
        // 当前弹出层，防止ID被覆盖
       let parentIndex = layer.index;
        //监听提交
        form.on('submit(updateSubmit)',function (data) {
            //获取表单中的数据信息
            let dt =data.field;
            if(dt.newPwd == dt.confirmPwd){
                $.ajax({
                    url:'user/changePassword.do',
                    type:"post",
                    data:dt,
                    dataType:'JSON',
                    success:function (result) {
                        if(result.code==200){
                            layer.msg(result.msg,{
                                iocn:6,
                                time:1000
                            },function () {
                                //重载父窗口 关闭当前窗口
                                parent.window.location.reload();
                                var iframeIndex=parent.layer.getFrameIndex(window.name);
                                parent.layer.close(iframeIndex);
                                window.location = 'login.html';
                            })
                        }else{
                            layer.msg(result.msg);
                        }
                    }
                })
                return true;
            }else{
                layer.msg("两次密码输入不一致",{time:2000})
                return false;
            }

        });

    });
</script>